package com.chuanke.ckfamily.action.base;

import com.chuanke.ckfamily.service.base.FailCode;
import com.chuanke.ckfamily.service.exception.CFException;

public class Response {

    private boolean success;

    private int failCode;

    private String msg;
    
    private Long time;

    private Object data;

	public Response(Object data) {
        this.success = true;
        this.data = data;
    }

    public Response(FailCode failCode, String msg) {
        this.success = false;
        this.failCode = failCode.getCode();
        this.msg = msg;
    }

    public Response(CFException cfException) {
        this.success = false;
        this.failCode = cfException.getCode();
        this.msg = cfException.getMsg();
    }
    public Response(Exception exception) {
        this.success = false;
        this.failCode = FailCode.APP.getCode();
        this.msg = FailCode.APP.getMsg();
    }
    
    public Response(FailCode failCode) {
        this.success = false;
        this.failCode = failCode.getCode();
        this.msg = failCode.getMsg();
    }
  

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public int getFailCode() {
        return failCode;
    }

    public void setFailCode(int failCode) {
        this.failCode = failCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
    public Long getTime() {
 		return time;
 	}

 	public void setTime(Long time) {
		this.time = time == null ? System.currentTimeMillis() : time;
 	}
}
